/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.resrev.web;

import com.rafkind.resrev.dao.UserDao;
import com.rafkind.resrev.web.page.CalendarPage;
import org.apache.wicket.Page;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;

/**
 *
 * @author dave
 */
public class Application extends WebApplication {
  
  private UserDao userDao;
  
  private String title;
  private String licencee;
  private String adminEmail;
  private String homeUrl;
  private String version;
  
  public Application() {
  }

  @Override
  protected void init() {
    super.init();
    
    addComponentInstantiationListener(
        new SpringComponentInjector(this));    
    
    getSecuritySettings()
        .setAuthorizationStrategy(new AuthorizationStrategy());
    
    userDao.ensureAdminUserExists();    
  }

  @Override
  public Session newSession(Request request, Response response) {
    //System.out.println("---\n--- Creating a new session object!\n---\n");
    return new Session(request);
  }

  @Override
  public Class<? extends Page> getHomePage() {
    return CalendarPage.class;
  }

  public UserDao getUserDao() {
    return userDao;
  }

  public void setUserDao(UserDao userDao) {
    this.userDao = userDao;
  }

  public String getAdminEmail() {
    return adminEmail;
  }

  public void setAdminEmail(String adminEmail) {
    this.adminEmail = adminEmail;
  }

  public String getHomeUrl() {
    return homeUrl;
  }

  public void setHomeUrl(String homeUrl) {
    this.homeUrl = homeUrl;
  }

  public String getLicencee() {
    return licencee;
  }

  public void setLicencee(String licencee) {
    this.licencee = licencee;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public String getVersion() {
    return version;
  }

  public void setVersion(String version) {
    this.version = version;
  }
  
  
}